//
//  SPVViewController.m
//  SelectPhotosOrVideoContentViewLib
//
//  Created by dubaoquan on 01/08/2019.
//  Copyright (c) 2019 dubaoquan. All rights reserved.
//

#import "SPVViewController.h"
#import "SelectImageOrVideoContentView.h"
#import "AppConst.h"

@interface SPVViewController ()

@end

@implementation SPVViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    WEAK_SELF(weakSelf)
    CGFloat height = [SelectImageOrVideoContentView defaultViewHeight];
    
    UIView *photoAndVideosContentView = [[UIView alloc] init];
    SelectImageOrVideoContentView *mediaView = [[SelectImageOrVideoContentView alloc] initWithFrame:CGRectMake(0,100, SCREENWIDTH, height)];
    mediaView.delegate = self;
    mediaView.showDelete = YES;
    mediaView.showAddButton = YES;
    mediaView.allowMultipleSelection = NO;
    mediaView.allowPickingVideo = YES;
    
    [mediaView observeViewHeight:^(CGFloat mediaHeight) {
        NSLog(@"mediaHeight:%f",mediaHeight);
        
    }];
    
    [mediaView observeSelectedMediaArray:^(NSArray<ACMediaModel *> *list) {
        STRONG_SELF(strongSelf)
        //strongSelf.onlyHasVideo = YES;
        //        NSInteger videoCount = 0;
        for (ACMediaModel *model in list) {
            if(model.isVideo){
                mediaView.showAddButton = NO;
            }else{
                //strongSelf.onlyHasVideo = NO;
            }
            
        }
        // weakSelf.ACMediaList = list;
        
    }];
    [self.view addSubview:mediaView];
}

-(void)selectMediaViewTaped{
    [self.view endEditing:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
